<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<input type="button" value="浪子心声" onclick="getLyrics('lzxs')" />
	<input type="text" id="number" />
	<input type="text" id="password" />
	<input type="button" value="浪子心声" onclick="postLyrics()" />
	<span id="showLyrics"></span>

	<script type="text/javascript">
		var xmlhttp;
		function createXMLHttpRequext() {
			if (window.ActiveXObject) {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} else if (window.XMLHttpRequest) {
				xmlhttp = new XMLHttpRequest();
			}
		}
		function getLyrics(songName) {
			createXMLHttpRequext();

			//xmlhttp.open("GET", "dealData?songName=" + songName, true);
			xmlhttp.open("GET", "AjaxTest", true);
			//xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
			xmlhttp.onreadystatechange = returnLyrics;
			xmlhttp.send(null);

		}
		function postLyrics() {
			var content = "userNumber=" + document.getElementById("number").value + "&password=" + document.getElementById("password").value;
			
			createXMLHttpRequext();

			//xmlhttp.open("GET", "dealData?songName=" + songName, true);
			xmlhttp.open("POST", "AjaxTest", true);
			//xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			//xmlhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
			xmlhttp.onreadystatechange = returnLyrics;
			xmlhttp.send(content);

		}
		function returnLyrics() {
			
			if (xmlhttp.readyState == 4) {
				var lyrics = xmlhttp.responseText;
				alert(lyrics)
				document.getElementById("showLyrics").innerHTML = lyrics;
			}
		}

	</script>
</body>
</html>